#ifndef MESSAGE_PROCESSOR_H
#define MESSAGE_PROCESSOR_H

#include <functional>
#include <unordered_map>
#include <google/protobuf/message.h>
#include "connection.h"

class MessageProcessor {
public:
    // 注册消息类型和对应的处理函数
    void register_handler(uint32_t msg_type, std::function<void(const google::protobuf::Message&, std::shared_ptr<Connection>)> handler);
    void process(const char* data, size_t length, uint32_t msg_type, std::shared_ptr<Connection> connection);

private:
    std::unordered_map<uint32_t, std::function<void(const google::protobuf::Message&, std::shared_ptr<Connection>)>> handlers_;
};

#endif